#
# Copyright 2014-2016 CyberVision, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This file is generated by CppEventSourcesGenerator.java
# from client-cpp/templates/event/AvroStructGenerator.cmake.template

find_program(avrogen avrogencpp)

if (${avrogen} STREQUAL "avrogen-NOTFOUND")
    message(FATAL_ERROR "avrogen is NOT found")
else()
    message("Generating necessary files according to Avro schemas")
endif()

if (WIN32)
    set(directory_separator "\\")
else()
    set(directory_separator "/")
endif()

set(avro_schemas ${CMAKE_CURRENT_SOURCE_DIR}${directory_separator}avro${directory_separator})
set(kaa_headers ${CMAKE_CURRENT_SOURCE_DIR}${directory_separator}kaa${directory_separator})

file(MAKE_DIRECTORY ${avro_schemas}event ${kaa_headers}gen)

execute_process(COMMAND ${avrogen}
    -i ${avro_schemas}endpoint.avsc
    -o ${kaa_headers}gen${directory_separator}EndpointGen.hpp
    -n kaa)
execute_process(COMMAND ${avrogen}
    -i ${avro_schemas}profile.avsc
    -o ${kaa_headers}profile${directory_separator}gen${directory_separator}ProfileGen.hpp
    -n kaa_profile)
execute_process(COMMAND ${avrogen}
    -i ${avro_schemas}notification.avsc
    -o ${kaa_headers}notification${directory_separator}gen${directory_separator}NotificationGen.hpp
    -n kaa_notification)
execute_process(COMMAND ${avrogen}
    -i ${avro_schemas}log.avsc
    -o ${kaa_headers}log${directory_separator}gen${directory_separator}LogGen.hpp -n kaa_log)
execute_process(COMMAND ${avrogen}
    -i ${avro_schemas}configuration.avsc
    -o ${kaa_headers}configuration${directory_separator}gen${directory_separator}ConfigurationGen.hpp
    -n kaa_configuration)

set(event_family_classes "")

foreach(family ${event_family_classes})
    execute_process(COMMAND ${avrogen}
        -i ${avro_schemas}event${directory_separator}${family}.avsc
        -o ${kaa_headers}event${directory_separator}gen${directory_separator}${family}Gen.hpp
        -n ns${family})
endforeach(family)
